package com.ruoyi.system.utils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 读取CSV文件的具体方法
 */
public class CSVReader {

    private String filename;

    public CSVReader(String filename) {
        this.filename = filename;
    }

    public List<String[]> read() throws IOException {
        List<String[]> data = new ArrayList<>();
        try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
            String line;
            boolean firstLine = true;
            while ((line = br.readLine()) != null) {
                if (firstLine) {  // 跳过第一行标题行
                    firstLine = false;
                    continue;
                }
                String[] fields = line.split(",");
                data.add(fields);
            }
        }
        return data;
    }
}
